Page({
  data: {
    details: null,
    isEdit: false,
    nextStep: false,
    patients: null,
    selectedPatient: null,
    radio: -1,
    imgs: []
  },
  onShow(){
    this.setData({patients: getApp().globalData.patients,selectedPatient: getApp().globalData.selectedPatient});
  },
  edit(){
    this.setData({isEdit: true});
  },
  offEdit(){
    if(this.data.isEdit)this.setData({isEdit: false});
  },
  nextStep(){
    this.setData({nextStep: true});
    // this.animate('.showcase-front', [
    //   { translateY: 0, ease: 'ease' },
    //   { translateY: '-150%' },
    //   ],640, function () {
    // }.bind(this))
    this.animate('.showcase-front',[{translateY: '-250%',opacity: 0}],640);
    this.animate('.showcase-back',[{translateY: '-170%',opacity: 1}],640);
  },
  toAddPatient(){
    wx.navigateTo({
      url: '../../patient/addPatient',
    });
  },
  switchPatient(event){
    this.setData({selectedPatient: event.currentTarget.dataset.index});
  },
  switchRadio(event){
    this.setData({radio: event.currentTarget.dataset.index});
  },
  toConsult(){
    getApp().globalData.consultImgs = this.data.imgs;
    getApp().globalData.consultDetails = this.data.details;
    wx.redirectTo({
      url: '../chatRoom/chatRoom',
    });
  },
  selectImg(){
    let _this = this;
    wx.chooseImage({
      count: 1,
      success(res){
        const tempFilePaths = res.tempFilePaths;
        _this.data.imgs.push(tempFilePaths[0]);
        _this.setData({imgs: _this.data.imgs});
      }
    })
  }
})